package com.sxfq.gds.backweb.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.sxfq.gds.api.system.facade.UserApi;
import com.sxfq.gds.api.system.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Administrator on 2017/7/16.
 */
@RestController
@RequestMapping("/system")
public class SystemController {

    @Autowired
    private DiscoveryClient discoveryClient;//激活Eureka中的DiscoveryClient实现

    @Autowired
    UserApi api;


//    @HystrixCommand(fallbackMethod = "callRecommendFallback", commandProperties = {
//    @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "100")
//    })
    @HystrixCommand(fallbackMethod = "callRecommendFallback")
    @RequestMapping("/test")
    public String test(){
        User user=api.test();
        return "1113";
    }

    public String callRecommendFallback() {
        return "hystrix 返回";
    }
}
